#ifndef __WORLD__
#define __WORLD__

#include <iostream>
#include <vector>
#include <ode/ode.h>
#include <SDL/SDL.h>

#include "Touchable.hh"
#include "Renderable.hh"
#include "Camera.hh"
#include "Path.hh"
#include "Patterns.hh"

using namespace std;

// Singleton-ed
class World: public Singleton<World> {
public:
  World();
  World(SDL_Surface* screen);

  ~World();
  
  void SetGravity(dReal x, dReal y, dReal z);

  void SetCFM(dReal cfm);

  void AddEntity(Renderable* r);
  void AddEntity(Touchable* t);

  void AddCamera(Camera* c);
  
  void SelectCamera(unsigned int i);

  void OdeSim();
  
  dWorldID GetWorld();

  void Render();

  void PrintAllNames();

  //  void collisionHandler(void *dataUnused, dGeomID o1, dGeomID o2);
  //  void nearCallback(void *unused, dGeomID o1, dGeomID o2);
  

  int MainLoop();

private:

  static dWorldID sOdeWorld;
  static dSpaceID sSpace;

  SDL_Surface* mScreen;

  vector<Renderable*> mRenderableList;
  vector<Touchable*>  mTouchableList;
  vector<Renderable*>::iterator mItR;
  vector<Touchable*>::iterator mItT;

  vector<Camera*> mCameraList;
  vector<Camera*>::iterator mItC;
  
  unsigned int mSelectedCamera;

  dJointGroupID mContactgroup;

  
};

#endif
